﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using Microsoft.SilverlightMediaFramework.Core;
using Microsoft.SilverlightMediaFramework.Core.Media;
using System.Collections.ObjectModel;
using Microsoft.SilverlightMediaFramework.Plugins.Primitives;

namespace Ausy.Silverlight.VideoPlayer.MediaModule.Extensions.Converters
{
    /// <summary>
    /// Cette classe représente un convertisseur d'une Uri d'une vidéo en PlayList contenant 1 item 
    /// </summary>
    public class UriPlayListConverter : IValueConverter
    {
        /// <summary>
        /// Cettte méthode permet de convertir une Uri en PlayList
        /// </summary>
        /// <param name="value">Uri</param>
        /// <param name="targetType">PlayList</param>
        /// <param name="parameter">Empty</param>
        /// <param name="culture">Empty</param>
        /// <returns>PlayList</returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var collection = new ObservableCollection<PlaylistItem>();
            var uri = value as Uri;
            if (uri != null)
            {
                collection.Add(new PlaylistItem() { MediaSource = uri, DeliveryMethod = DeliveryMethods.ProgressiveDownload });
            }
            return collection;
        }

        /// <summary>
        /// Méthode non implémenté
        /// </summary>
        /// <param name="value">PlayList</param>
        /// <param name="targetType">ObservableCollectionPlaylistItem</param>
        /// <param name="parameter">Empty</param>
        /// <param name="culture">Empty</param>
        /// <returns>Uri</returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
